
<?php
include("include/haut.php");

if(!isConnected() OR !isset($_GET['id']) OR !idExiste(htmlentities($_GET['id']))){
	header("Location: index.php");
	exit();
}

$id = htmlentities($_GET['id']);

$prof = getInfos($id);
?>

<div id="corps">
	<h1>Mon Profil</h1>
	<div id="centre">
		<?php
		if(estAdmin($user) OR $_SESSION['id'] == $prof['id']){
			echo '<a href="modif_profil.php?id='.$prof['id'].'">Modifier les informations</a>';
			
		}
		if(estAdmin($user)){
			?> <br/><?php
			echo '<a href="modif_profil.php?id='.$prof['id'].'&action=delete">Supprimer le membre</a>';
		}
		?>
		<div id="profil_tb"/>
		<h2>Informations Générales</h2>
		<table style="width: 100%;">

			<tr>
			<td>Pseudo :</td><td><?php echo $prof['pseudo']; ?></td>
			</tr>
			<tr><td>Statut :</td><td><?php echo $prof['statut']; ?></td>
		    </tr> 
			<tr><td>Age:</td><td><?php echo getAge($prof['age'])." ans"; ?></td>
			</tr>
			<tr>
			<td>Ville :</td>
			<td>
			<?php
			echo $prof['ville'];
			 ?>
			 </td></tr>
			 			<td>Inscrit depuis :</td>
			<td>
			<?php
			echo tmptojour($prof['jours'])." jours";
			 ?>
			 </td>
			</tr>
		</table>

		<!--  -->

		<h2>Informations Complémentaires</h2>
		<table style="width: 100%;margin-left:8%;">
			<?php
			if($prof['privacy_np'] == 1){
				if($_SESSION['id'] == $prof['id']){
					echo "<em>Vous n'avez pas souhaité partager ces informations</em>";
				}
				else{
					echo "<em>Le membre ne souhaite pas partager ses informations</em>";
				}
			}
			else
			{
				if($prof['privacy_np'] == 0){
				if($_SESSION['id'] == $prof['id']){
					echo "<em>Vous avez choisi d'afficher ces informations : </em>";
				}
			}
				?>
				<tr>
				<td>Nom:</td><td><?php echo $prof['prenom']; ?></td>
				</tr>
				<tr><td>Prénom :</td><td><?php echo $prof['nom']; ?></td>
			    </tr> 
				<tr><td>Email:</td><td><?php echo $prof['email']; ?></td>
				</tr>
				<?php
				if($prof['num'] == 0){?>
					<tr><td>Téléphone:</td><td>N/A</td>
				<?php }else{?>
				<tr><td>Téléphone:</td><td><?php echo "0".$prof['num']; ?></td>
					<?php 
				}
					?>
				</tr>
				<tr>
				<td>Facebook :</td><td>
				<?php
				if($prof['facebook'] == "N/A"){
				 echo "N/A";}
				 else{
				 	echo '<a href="'.$prof['facebook'].'"><img src="img/misc/fb.gif" />';
				 }
				 ?>
				 </td>
				</tr>
				<?php
			}
			?>

		</table>
	</div>
</div>
</div>
<?php
include("include/bas.php");
?>
